home *** CD-ROM | disk | FTP | other *** search
- PRAGMA LIST(On);
-
- WITH Ada.Text_IO; USE Ada.Text_IO;
-
- PROCEDURE Factorial IS
- FUNCTION Fat(N : Integer) RETURN Integer IS
- BEGIN
- IF N <= 1 THEN
- RETURN 1;
- ELSE
- RETURN N * Fat(N - 1);
- END IF;
- EXCEPTION
- WHEN Numeric_Error =>
- return -1;
- END Fat;
- BEGIN
- FOR I IN 2 .. 8 LOOP
- Put("O Fatorial de ");
- Put(Integer'IMAGE(I));
- Put(" e' ");
- Put_Line(Integer'IMAGE(Fat(I)));
- END LOOP;
- END Factorial;